﻿namespace Creek.Serialize.Serializing
{
    using System;
    using System.Collections.ObjectModel;

    ///<summary>
    ///</summary>
    public sealed class TypeInfoCollection : KeyedCollection<Type, TypeInfo>
    {
        #region Public Methods and Operators

        /// <summary>
        /// </summary>
        /// <returns> null if the key was not found </returns>
        public TypeInfo TryGetTypeInfo(Type type)
        {
            if (!Contains(type))
            {
                return null;
            }
            return this[type];
        }

        #endregion

        #region Methods

        /// <summary>
        /// </summary>
        /// <param name="item"> </param>
        /// <returns> </returns>
        protected override Type GetKeyForItem(TypeInfo item)
        {
            return item.Type;
        }

        #endregion
    }
}